package com.huawei.hwid.core.d;

import android.content.Context;
import com.huawei.hwid.core.d.b.e;
import java.lang.reflect.Field;

public class l {
    public static int a(Context context, String str, String str2) {
        try {
            int identifier = context.getResources().getIdentifier(str2, str, context.getPackageName());
            if (identifier != 0) {
                return identifier;
            }
            Field field = Class.forName(context.getPackageName() + ".R$" + str).getField(str2);
            identifier = Integer.parseInt(field.get(field.getName()).toString());
            if (identifier != 0) {
                return identifier;
            }
            e.b("ResourceLoader", "resourceId == 0", true);
            return identifier;
        } catch (ClassNotFoundException e) {
            e.d("ResourceLoader", "!!!! ResourceLoader: reflect resource ClassNotFoundException", true);
            return 0;
        } catch (NumberFormatException e2) {
            e.d("ResourceLoader", "!!!! ResourceLoader: reflect resource NumberFormatException", true);
            return 0;
        } catch (LinkageError e3) {
            e.d("ResourceLoader", "!!!! ResourceLoader: reflect resource LinkageError", true);
            return 0;
        } catch (IllegalArgumentException e4) {
            e.d("ResourceLoader", "!!!! ResourceLoader: reflect resource IllegalArgumentException", true);
            return 0;
        } catch (IllegalAccessException e5) {
            e.d("ResourceLoader", "!!!! ResourceLoader: reflect resource IllegalAccessException", true);
            return 0;
        } catch (RuntimeException e6) {
            e.d("ResourceLoader", "!!!! ResourceLoader: reflect resource RuntimeException", true);
            return 0;
        } catch (Exception e7) {
            e.d("ResourceLoader", "!!!! ResourceLoader: reflect resource Exception", true);
            return 0;
        }
    }

    public static int a(Context context, String str) {
        return a(context, "string", str);
    }

    public static int b(Context context, String str) {
        return a(context, "xml", str);
    }

    public static int c(Context context, String str) {
        return a(context, "layout", str);
    }

    public static int d(Context context, String str) {
        return a(context, "id", str);
    }
}
